package com.bbs.toutiao.service.admin.impl;

import com.bbs.toutiao.aspect.SysLog;
import com.bbs.toutiao.mapper.admin.CommentMapper;
import com.bbs.toutiao.service.admin.CommentService;
import com.bbs.toutiao.vo.comm.PageVo;
import com.bbs.toutiao.vo.comment.ComResponseVo;
import com.bbs.toutiao.vo.comment.CommentPageRequestVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 描述: 评论操作
 * 作者： zhangBin
 * 时间： 2023/9/25 17:02
 * 版本： 1.0
 */

@Service
public class CommentServiceImpl implements CommentService {

    @Resource
    CommentMapper commentMapper;

    //分页查询评论
    @Override
    public PageVo<ComResponseVo> findByCommentPage(CommentPageRequestVo requestVo) {
        List<ComResponseVo> list = commentMapper.findByCommentPage(requestVo);
        PageVo<ComResponseVo> responseVoPageVo = new PageVo<>();
        long i = commentMapper.getCommentCount(requestVo);
        responseVoPageVo.setPageList(list);
        responseVoPageVo.setTotal(i);
        return responseVoPageVo;
    }

    //动态删除评论
    @SysLog("客户端删除了评论")
    @Transactional
    @Override
    public int deleteByIdComment(List<Map<String, Integer>> commtList) {
        return commentMapper.deleteByIdComment(commtList);
    }
}
